package com.cande.loki.exercise.javabasic;

/**
 * @auther ROCK CODER
 * @DATE 2022/6/21 19:28
 * @Description
 */
public class TestThreadLocal {
    public static void main(String[] args) throws InterruptedException {

        ThreadLocal<Integer> local = new ThreadLocal<>();
        local.set(4);
        local.set(5);
//        try {


            new Thread(() -> {

                while (true){
                    if (local.get()!=null){
                        System.out.println("this is a runnable thread");
                    }
//                    System.out.println("sub"+local.get());
//                    local.remove();

                }
//                throw new RuntimeException();
            }).start();

//        }catch (Exception e){
//            System.out.println("捕获到了");
//        }
        Thread.sleep(1000);
        System.out.println(local.get());

    }
}
